home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / libc / Quad_AddUnsLong.c < prev    next >
C/C++ Source or Header  |  1991-03-18  |  1KB  |  54 lines

  1. /* 
  2.  * Quad_AddUnsLong.c --
  3.  *
  4.  *    Quad_AddUnsLong libc routine.
  5.  *
  6.  * Copyright 1991 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that this copyright
  10.  * notice appears in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/quad/RCS/Quad_AddUnsLong.c,v 1.1 91/03/18 12:19:06 kupfer Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20. #include <quad.h>
  21.  
  22.  
  23. /*
  24.  *----------------------------------------------------------------------
  25.  *
  26.  * Quad_AddUnsLong --
  27.  *
  28.  *    Add an unsigned long to an unsigned quad.
  29.  *
  30.  * Results:
  31.  *    The sum of the two values.
  32.  *
  33.  * Side effects:
  34.  *    None.
  35.  *
  36.  *----------------------------------------------------------------------
  37.  */
  38.  
  39. void
  40. Quad_AddUnsLong(uQuad, uLong, resultPtr)
  41.     u_quad uQuad;        /* in */
  42.     u_long uLong;        /* in */
  43.     u_quad *resultPtr;        /* out */
  44. {
  45.     unsigned long newLeastSig;
  46.  
  47.     newLeastSig = uQuad.val[QUAD_LEAST_SIG] + uLong; 
  48.     resultPtr->val[QUAD_MOST_SIG] = uQuad.val[QUAD_MOST_SIG];
  49.     if (newLeastSig < uQuad.val[QUAD_LEAST_SIG] && newLeastSig < uLong) { 
  50.     resultPtr->val[QUAD_MOST_SIG]++; 
  51.     } 
  52.     resultPtr->val[QUAD_LEAST_SIG] = newLeastSig; 
  53. }
  54.